


#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

class Solution
{
public:
    int subarraySum1(vector<int>& nums, int k)
    {
        int n = nums.size();
        int res = 0, sum = 0;
        unordered_map<int, int> hash;

        for (const auto i : nums)
        {
            sum += i;

            if (sum == k)
                ++res;
            if (hash[sum - k])
                res += hash[sum - k];
            ++hash[sum];
        }

        return res;
    }

    int subarraySum2(vector<int>& nums, int k)
    {
        int sum = 0;
        int cnt = 0;
        int n = nums.size();


        for (int i = 0; i < n; ++i)
        {
            sum = 0;
            for (int j = i; j < n; ++j)
            {
                sum += nums[j];
                if (sum == k)
                    ++cnt;
            }
        }

        return cnt;
    }

};

int main()
{


	return 0;
}